#include <bits/stdc++.h>
using namespace std;
const int n = 8;
int ans = 0;
int g[n + 1]; 
bool check(int y2)
{
    for (int y1 = 1; y1 < y2; y1++)
    {
        if (g[y2] == g[y1] || y2 - y1 == abs(g[y2] - g[y1]))
        /**
         * 1. 检查走过的行中有无同一列放置的皇后
           2. 检查走过的行中有无同一斜线放置的皇后(通过斜率判断)
        */
           return false;
    }
    return true;
}
void dfs(int y2)
    if (y2 > n)
    {
        ans++;
        return;
    }
    for (int x2 = 1; x2 <= n; x2++) 
        g[y2] = x2;
        if (check(y2))
        {
            dfs(y2 + 1); 
        }
    }
}

int main()
{

    dfs(1);
    cout << ans;
}